import request from "@/utils/request"

const USER_ROLE_BASE_URL = "/api/object/com.siline.chimes/ChimesUsersRoles"

class UserRoleAPI {
  /**
   * 添加用户角色
   *
   * @param data 用户角色表单数据
   */
  static add(data: UserRoleForm) {
    return request({
      url: `${USER_ROLE_BASE_URL}/insert`,
      method: "post",
      data: data,
    })
  }

  /**
   * 根据条件删除
   */
  static deleteBy(data: QueryCondition) {
    return request({
      url: `${USER_ROLE_BASE_URL}/delete_by`,
      method: "post",
      data,
    })
  }

  /** 批量添加用户角色 */
  static saveBatch(data: UserRoleForm[]) {
    return request({
      url: `${USER_ROLE_BASE_URL}/save_batch`,
      method: "post",
      data: data,
    })
  }
}

export default UserRoleAPI

export interface UserRoleForm {
  user_id: number
  role_id: number
}
